#include<stdio.h>       // 输入输出
#include<stdlib.h>      // 工具包
#include<time.h>        // 时间
#include<stdatomic.h>   // 原子操作
#include <unistd.h>     // 调用 sleep() 函数
#include <pthread.h>    // 调用 pthread_create() 函数

/*
gcc -std=c11 -m64 -pthread test-memory.c -o a.out
./a.out
*/
const size_t LIZI_COUNT = (1024) * sizeof(long);
#define LIZI_X 512
#define LIZI_Y 1024
#define LIZI_Z 1024
static long liziArr[LIZI_X][LIZI_Y][LIZI_Z];

int main(){
    printf("sizeof(long): %ld\n",sizeof(long));
    time_t startTime,endTime;
    clock_t startClock,endClock;

    time(&startTime);

    
    // // 申请内存
    // long* p =  (long*)malloc(LIZI_COUNT);
    
for (int i = 0; i < 100; i++)
{
    
    startClock = clock();
    printf("liziArr[10][10][10]=%ld\n", liziArr[10][10][10]);
    for (int x = 0, num=0; x < LIZI_X; x++) {
        for (int y = 0; y < LIZI_X; y++) {
            for (int z = 0; z < LIZI_X; z++) {
                liziArr[x][y][z] = num++;
            }
        }
    }
    printf("liziArr[10][10][10]=%ld\n", liziArr[10][10][10]);
    endClock = clock();
    printf("%d,翻一遍地, 耗时=%.3fs\n", i,(double)(endClock - startClock) / CLOCKS_PER_SEC);
}


    time(&endTime);
    printf("运行时间%fs\n", difftime(endTime,startTime));
    return 0;
}